FreeSurfer Voxels and Meshes¶
NIfTI and GIFTI are popular neuroimaging formats for voxels and meshes. However, FreeSurfer will often generate its own internal formats. This notebook displays FreeSurfer data.
In [1]:
from pathlib import Path
from ipyniivue import download_dataset
BASE_API_URL = "https://niivue.com/demos/images/fs/"
DATA_FOLDER = Path("images/fs")
download_dataset(
BASE_API_URL,
DATA_FOLDER,
files=[
"brainmask.mgz",
"rh.pial",
"rh.white",
],
)
Downloading brainmask.mgz... Downloading rh.pial...
Downloading rh.white... Dataset downloaded successfully to images/fs.
In [2]:
from pathlib import Path
from ipyniivue import NiiVue, SliceType
## Initialize Viewer
nv = NiiVue(slice_type=SliceType.MULTIPLANAR)
## Load Volume and Surfaces
nv.load_volumes([{"path": DATA_FOLDER / "brainmask.mgz"}])
nv.load_meshes(
[
{"path": DATA_FOLDER / "rh.pial", "rgba255": [64, 22, 222, 255]},
{"path": DATA_FOLDER / "rh.white", "rgba255": [222, 194, 0, 255]},
]
)
## Configure Display Settings
nv.set_clip_plane(-0.1, 270, 0)
nv.set_mesh_shader(nv.meshes[0].id, "crosscut")
nv.set_mesh_shader(nv.meshes[1].id, "crosscut")
## Display Viewer
nv
Out[2]: